package com.augurit.wf.common.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.augurit.common.base.dao.BaseDao;
import com.augurit.wf.common.entity.Jbpm4Participant;

@Repository
public class Jbpm4ParticipantDao extends BaseDao<Jbpm4Participant, Long>{
	
	/**
	 * 根据taskId获取待领取关系
	 * @param taskId
	 */
	public List<Jbpm4Participant> getParticipantsByTaskId(String taskId){
		List<Jbpm4Participant> list = null;
			if(taskId != null){
			String hql = "from Jbpm4Participant ps where ps.task='" + taskId +"'";
			list = this.find(hql);
		}
		return list;
	}
	
	/**
	 * 根据taskId清除待领取关系
	 * @param taskId
	 */
	public void clearParticipantsByTaskId(String taskId){
		if(taskId != null){
			List<Jbpm4Participant> list = getParticipantsByTaskId(taskId);
			if(list != null && list.size()>0){
				for(Jbpm4Participant entity : list)
					this.delete(entity);
			}
		}
	}
}
